
# Makefile for Minirel
#

.SUFFIXES: .o .cpp

#
# Compiler and loader definitions
#

LD =		ld
LDFLAGS =	

CXX =		g++
CXXFLAGS =	-g -Wall -DDEBUG 
# CXXFLAGS =	-O -Wall -DDEBUG 

MAKEFILE =	Makefile

#
# list of all object and source files
#

MROBJS =	error.o heapfile.o index.o print.o insert.o select.o \
		scanselect.o indexselect.o snl.o smj.o inl.o join.o sort.o

MISCOBJS =	load.o quit.o delete.o

CATOBJS =	relCat.o attrCat.o idxCat.o 

LSMOBJS = 	buf.o bufMap.o db.o page.o 

CLOBJS =	db.o error.o index.o insert.o \
		dbcreate.o dbdestroy.o select.o scanselect.o \
		indexselect.o snl.o smj.o inl.o join.o sort.o minirel.o heapfile.o print.o

TESTIDXOBJS =	db.o buf.o bufMap.o error.o page.o heapfile.o index.o \
		testindex.o

DBOBJS =	print.o error.o heapfile.o index.o

SRCS =		db.cpp error.cpp sort.cpp testsort.cpp index.cpp \
		attrCat.cpp relCat.cpp idxCat.cpp load.cpp print.cpp \
		quit.cpp insert.cpp delete.cpp select.cpp scanselect.cpp \
                indexselect.cpp snl.cpp smj.cpp inl.cpp join.cpp minirel.cpp \
		dbcreate.cpp dbdestroy.cpp 

LIBS =		libsql.a libcat.a libmisc.a liblsm.a 

all:		minirel dbcreate dbdestroy

ts:	ts.o $(MROBJS) 
		$(CXX) -o $@ $@.o $(MROBJS) $(LIBS) $(LDFLAGS) -lm

minirel:	minirel.o $(MROBJS) 
		$(CXX) -o $@ $@.o $(MROBJS) $(LIBS) $(LDFLAGS) -lm

dbcreate:	dbcreate.o $(DBOBJS) 
		$(CXX) -o $@ $@.o $(DBOBJS) liblsm.a libcat.a $(LDFLAGS) -lm

dbdestroy:	dbdestroy.o
		$(CXX) -o $@ $@.o

libcat.a:	$(CATOBJS)       
		ar -cr $@ $(CATOBJS)

libmisc.a:	$(MISCOBJS)       
		ar -cr $@ $(MISCOBJS)

liblsm.a:	$(LSMOBJS)       
		ar -cr $@ $(LSMOBJS)

libsql.a:        
		(cd parser; make gen; make)

testindex:	$(TESTIDXOBJS) 
		$(CXX) -o $@ $(TESTIDXOBJS) $(LDFLAGS) -lm

minirel.pure:	minirel.o $(MROBJS) $(LIBS)
		$(PURIFY) $(CXX) -o $@ minirel.o $(MROBJS) $(LIBS) $(LDFLAGS) -lm

dbcreate.pure:	dbcreate.o $(DBOBJS) liblsm.a libcat.a
		$(PURIFY) $(CXX) -o $@ dbcreate.o $(DBOBJS) liblsm.a libcat.a $(LDFLAGS) -lm

.cpp.o:
		$(CXX) $(CXXFLAGS) -c $<

pristine:
		(make clean; cd parser; make pristine)

clean:
		rm -f core *.bak  $(CLOBJS) minirel dbcreate dbdestroy 



